package com.ch3cooh.api.service;

import org.springframework.amqp.AmqpException;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class MqService {

    @Autowired private AmqpTemplate rabbitTemplate;

    /**
     * 发送消息
     * @param   empId   员工id
     * @param msg   消息内容
     * @return
     */
    public boolean send(Integer empId,String msg){
        try {
            rabbitTemplate.convertAndSend("normal","员工["+empId+"], " + msg);
        }catch (AmqpException e){
            e.printStackTrace();
            return false;
        }
        return true;
    }

}
